using NL.Combat;

namespace NL.Advanced
{

    public class ATT : IAttacky
    {
        public float point;
        public float factor;

        public virtual float attack => point * (1 + factor);
        public ATT()
        {
            point = 0;
        }
        public ATT(float p, float fac)
        {
            point = p; factor = fac;

        }
        public ATT(string s)
        {
            point = 0; factor = 0;
            if (!string.IsNullOrEmpty(s))
            {
                var arr = s.Split(NLConst.CHAR_INNER);
                if (arr.Length > 0)
                    float.TryParse(arr[0], out point);
                if (arr.Length > 1)
                    float.TryParse(arr[1], out factor);
            }

        }
        public ATT AddAttack(ATT att)
        {
            point += att.point;
            factor += att.factor;
            return this;
        }

        public ATT AddAttack(string att)
        {
            AddAttack(new ATT(att));

            return this;
        }
        public ATT AddFactor(float _factor)
        {
            factor += _factor; return this;
        }



        public static ATT Zero => new ATT() { point = 0, };


        //                     denf
        ///   伤害减免   dd= -------------
        ///                   100+denf
        ///              att
        ///   最终伤害   hp= att*(1-dd)
        ///              
        ///           
        ///      
        public virtual HURT AttackAt(DENF denf, float factor = 1)
        {
            var dhp = attack  - denf.DD;
            //最后缩放因子...
            dhp *= factor;

            return new HURT() { life = dhp };

        }
    }
    public class DENF : IDefency
    {
        public float denfence;


        public int Group;

        public static DENF Zero => new DENF() { denfence = 0, };

        const float DENF_MAG = 100;
        public virtual float DD => (denfence) / (DENF_MAG + denfence);
    }

    public class HURT
    {
        public float life;

        public static float ATTACK_FLA = 15f;

        public HURT()
        {

        }

        //public AttackType type;






        public static HURT Zero => new HURT() { life = 0, };

        public override string ToString()
        {
            return $"life={life}";
        }

    }

    public struct HEAL
    {
        public float life;

        public static HEAL Zero => new HEAL() { life = 0, };
    }

}

